<?php

namespace app\common\model\merchant;

use think\Model;
use traits\model\SoftDelete;

class Merchant extends Model
{

    use SoftDelete;


    // 表名
    protected $name = 'merchant';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';


    const TYPE_COMPANY = 'company'; // 公司
    const TYPE_PERSON = 'person'; // 个体

    const WORK_TYPE_CAKE_BODY = 'cake_body'; //蛋糕体
    const WORK_TYPE_PRINTED_PAPER = 'printed_paper'; //平面贴图
    const WORK_TYPE_CUTTED_STICKER_EDIBLE = 'cutted_sticker_edible'; //贴片
    const WORK_TYPE_TOPPER = 'topper'; //蛋糕插件

    const STATUS_DISABLED = '-1'; // 禁用
    const STATUS_REVIEW = '0'; // 待审核
    const STATUS_ENABLED = '1'; // 启用


    public function getTypeList()
    {
        return [
            self::TYPE_COMPANY => __('Type company'),
            self::TYPE_PERSON  => __('Type person'),
        ];
    }

    public function getWorkTypeList()
    {
        return [
            self::WORK_TYPE_CAKE_BODY             => __('Work_type cake_body'),
            self::WORK_TYPE_PRINTED_PAPER         => __('Work_type printed_paper'),
            self::WORK_TYPE_CUTTED_STICKER_EDIBLE => __('Work_type cutted_sticker_edible'),
            self::WORK_TYPE_TOPPER                => __('Work_type topper')
        ];
    }

    public function getStatusList()
    {
        return ['-1' => __('Status -1'), '0' => __('Status 0'), '1' => __('Status 1')];
    }


    protected function setWorkTypeAttr($value)
    {
        return is_array($value) ? implode(',', $value) : $value;
    }


}
